package com.nd.mobile.study.domain;

import java.io.Serializable;

import android.os.Bundle;

import com.fuckhtc.gson.Gson;
import com.fuckhtc.gson.annotations.SerializedName;
import com.fuckhtc.gson.reflect.TypeToken;
import com.nd.mobile.study.common.config.Commands;
import com.nd.mobile.study.common.config.ReqParam;
import com.nd.mobile.study.common.util.HttpRequestUtil;
import com.nd.mobile.study.common.util.L;

public class BluebookCatalog implements Serializable {
	private static final long	serialVersionUID	= 5098889509721312430L;
	@SerializedName("BlueBookID")
	private String id;
	@SerializedName("BlueBookName")
	private String name;
	@SerializedName("TotalScore")
	private String sore;
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSore() {
		return sore;
	}
	public void setSore(String sore) {
		this.sore = sore;
	}
	private Bundle prepareReq(User user,Bluebook bluebook) {
		Bundle data = new Bundle();
		data.putString(ReqParam.BLUEBACK_ID, this.id);
		data.putString(ReqParam.COMMON_USER_ID, user.getUserId());
		if(bluebook!=null){
			data.putString(ReqParam.BBTID, String.valueOf(bluebook.getId()+1));
			data.putString(ReqParam.SERIAL_NUMBER, String.valueOf(bluebook.getSerialNum()+1));
			data.putString(ReqParam.PREV_BBTID, String.valueOf(bluebook.getId()));
			data.putString(ReqParam.PREV_PCID,bluebook.getPcID());
			data.putString(ReqParam.PREV_ANSWER,bluebook.getUserAnswer());
		}else{
			data.putString(ReqParam.BBTID, "0");
			data.putString(ReqParam.SERIAL_NUMBER, "0");
			data.putString(ReqParam.PREV_BBTID, "0");
			data.putString(ReqParam.PREV_PCID,"0");
			data.putString(ReqParam.PREV_ANSWER,"");
		}
		return data;
	}
	//"题目类别（0单选 1多选 2 分析题 3 是非题 4 填空题）
	public Result<Bluebook[]> getBlueBook(User user,Bluebook bluebook) throws Exception{
		String jsonData = HttpRequestUtil.get(Commands.GET_SUBJECT_EXAM_Q_DETAIL, prepareReq(user,bluebook));
//		String jsonData = "{\"ReturnInfo\":{\"BBTID\":\"题型号\","+
//				"\"TypeName\":\"题型说明\",\"SerialNumber\":\"1\",\"PCID\": \"1\","+
//				"\"ProblemTypeID\": \"0\","+
//				"\"ContentNote\" : \"这个是单选题\",\"Answer\" : \"[\"A\",\"B\",\"C\",\"D\"]\",\"TotalNumber\":\"总题数\"},"+ 
//				"\"PromptInfo\":\"提示信息\"}";
		L.i("---bluebook----", jsonData);
		Result<Bluebook[]> result = new Gson().fromJson(jsonData, new TypeToken<Result<Bluebook[]>>() {
		}.getType());
		return result;
	}
}
